package com.iyundao.io.mapper;

import com.iyundao.io.model.SysRole;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by black on 2019/4/23.
 */
@Repository
public interface SysRoleSqlMapper {
    @Select({
            "select ",
            "sys_role.sid, real_name, show_name, flag, create_date, create_id, orde_by",
            "from user_role ",
            "LEFT JOIN sys_role on user_role.rid = sys_role.sid and flag = 1 ",
            "where uid = #{uid,jdbcType=CHAR}"
    })
    @Results({
            @Result(column="sid", property="sid", jdbcType=JdbcType.CHAR, id=true),
            @Result(column="real_name", property="realName", jdbcType=JdbcType.VARCHAR),
            @Result(column="show_name", property="showName", jdbcType=JdbcType.VARCHAR),
            @Result(column="flag", property="flag", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_date", property="createDate", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="create_id", property="createId", jdbcType=JdbcType.CHAR),
            @Result(column="orde_by", property="ordeBy", jdbcType=JdbcType.TINYINT)
    })
    SysRole selectByUserId(String uid);
}
